package com.example.article.controller;


import com.example.api.common.R;
import com.example.api.entity.article.ArticlePraise;
import com.example.article.service.ArticlePraiseService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 点赞记录表 前端控制器
 * </p>
 *
 * @author lr
 * @since 2023-02-18
 */
@RestController
@RequestMapping("/article-praise-t")
@RequiredArgsConstructor
public class ArticlePraiseController {

    private final ArticlePraiseService articlePraiseService;

    /**
     * 新增
     *
     * @author zhengkai.blog.csdn.net
     * @date 2023/02/18
     **/
    @PutMapping("/insert")
    public Object insert(@RequestBody ArticlePraise articlePraise) {
        return articlePraiseService.insert(articlePraise);
    }

    /**
     * 刪除
     *
     * @author zhengkai.blog.csdn.net
     * @date 2023/02/18
     **/
    @RequestMapping("/delete")
    public R delete(int id) {
        return R.ok(articlePraiseService.delete(id));
    }

    /**
     * 更新
     *
     * @author zhengkai.blog.csdn.net
     * @date 2023/02/18
     **/
    @RequestMapping("/update")
    public R update(ArticlePraise ArticlePraise) {
        return R.ok(articlePraiseService.update(ArticlePraise));
    }

    /**
     * 查询 根据主键 id 查询
     *
     * @author zhengkai.blog.csdn.net
     * @date 2023/02/18
     **/
    @RequestMapping("/load")
    public R load(@Param("id") int id) {
        return R.ok(articlePraiseService.load(id));
    }

    /**
     * 查询 分页查询
     *
     * @author zhengkai.blog.csdn.net
     * @date 2023/02/18
     **/
    @RequestMapping("/pageList")
    public R pageList() {
        return R.ok(articlePraiseService.pageList());
    }
}
